#include <iostream>
class Button {
public:
    virtual void onClick() = 0;
};

class CheckBox
{
public:
    virtual void check() = 0;
};

class WinButton : public Button{
public:
    WinButton() {}

    void onClick() override {
        std::cout<<"WinButton click"<<std::endl;
    }
};

class WinCheckBox : public CheckBox{
public:
    void check() override {
        std::cout<<"WinCheckBox click"<<std::endl;
    }
};

class MacButton : public Button{
public:
    MacButton() {}

    void onClick() override {
        std::cout<<"MacButton click"<<std::endl;
    }
};

class MacCheckBox : public CheckBox{
public:
    void check() override {
        std::cout<<"MacCheckBox click"<<std::endl;
    }
};

class GUIFactory{
public:
    virtual Button*   createButton() = 0;
    virtual CheckBox* createCheckBox() = 0;
};

class WinFactory : public GUIFactory{
public:
    Button* createButton() override {
        return new WinButton();
    }
    CheckBox* createCheckBox() override {
        return new WinCheckBox();
    }
};

class MacFactory : public GUIFactory{
public:
    Button* createButton() override {
        return new MacButton();
    }
    CheckBox* createCheckBox() override {
        return new MacCheckBox();
    }
};

class Application
{
private:
    GUIFactory* factor = nullptr;
    Button *pB = nullptr;
    CheckBox *pC = nullptr;
public:
    explicit Application(GUIFactory* factor)
    {
        Application::factor = factor;
    }
    void createUI()
    {
        pB = factor->createButton();
        pC = factor->createCheckBox();
    }
    void paint()
    {
        pB->onClick();
        pC->check();
    }
};
int main() {
    GUIFactory* factory = new MacFactory();
    Application application(factory);
    application.createUI();
    application.paint();
    return 0;
}

